﻿using System;
using NiYo.ParserBuilder.Domain;
using NiYo.ParserBuilder.Exceptions;

namespace NiYo.ParserBuilder
{
    public interface IParserBuilder
    {
        /// <summary>
        /// Parse a message (from string) to an object model, without stating what type of message is expected 
        /// </summary>
        /// <param name="message">Message as string</param>
        /// <returns>A message in the type of that message</returns>
        /// <exception cref="ArgumentException">When message contains only spaces or is an empty string</exception>
        /// <exception cref="ArgumentNullException">When message is null</exception>
        /// <exception cref="ParseException">When something goes wrong during the parse</exception>
        /// <remarks>This method will try to detect the message type based on the message string. Settings cannot be provided because the type of message is unknown.</remarks>
        Message Parse(string message);

        /// <summary>
        /// Parse a message (from string) to an object model, without stating what type of message is expected 
        /// </summary>
        /// <param name="message">Message as string</param>
        /// <returns>A message in the type of that message</returns>
        /// <param name="feedback">Out parameter that contains the feedback from parsing</param>
        /// <exception cref="ArgumentException">When message contains only spaces or is an empty string</exception>
        /// <exception cref="ArgumentNullException">When message is null</exception>
        /// <exception cref="ParseException">When something goes wrong during the parse</exception>
        /// <remarks>This method will try to detect the message type based on the message string. Settings cannot be provided because the type of message is unknown.</remarks>
        Message Parse(string message, out Feedback feedback);

        /// <summary>
        /// Build a message (to string) from an object model
        /// </summary>
        /// <param name="message">Message as object</param>
        /// <returns>A string containing the message</returns>
        /// <exception cref="ArgumentNullException">When message is null</exception>
        /// <exception cref="BuildException">When something goes wrong during the build</exception>
        string Build(Message message);

        /// <summary>
        /// Build a message (to string) from an object model
        /// </summary>
        /// <param name="message">Message as object</param>
        /// <param name="feedback">Out parameter that contains the feedback during building</param>
        /// <returns>A string containing the message</returns>
        /// <exception cref="ArgumentNullException">When message is null</exception>
        /// <exception cref="BuildException">When something goes wrong during the build</exception>
        string Build(Message message, out Feedback feedback);
    }
}